
package com.epfresh.supplier.adapter;

import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.epfresh.api.universalimageloader.core.ImageLoader;
import com.epfresh.api.utils.LocalDisplay;
import com.epfresh.api.utils.T;
import com.epfresh.supplier.R;
import com.epfresh.supplier.entity.CategoryNames;

import multitype.ItemViewBinder;
import multitype.OnRecyclerViewItemClickListener;

public class HomeHeaderViewBinder
    extends ItemViewBinder<Integer, HomeHeaderViewBinder.ViewHolder> implements View.OnClickListener{

    OnRecyclerViewItemClickListener onRecyclerViewItemClickListener;

    public OnRecyclerViewItemClickListener getOnRecyclerViewItemClickListener() {
        return onRecyclerViewItemClickListener;
    }

    public void setOnRecyclerViewItemClickListener(OnRecyclerViewItemClickListener onRecyclerViewItemClickListener) {
        this.onRecyclerViewItemClickListener = onRecyclerViewItemClickListener;
    }

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(
            @NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View view = new FrameLayout(inflater.getContext());
        FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(0, LocalDisplay.dp2px(160));
        view.setLayoutParams(lp);
        return new ViewHolder(view);
    }


    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull Integer post) {
        holder.setData(post);

    }

    @Override
    public void onClick(View v) {

        Object tag = v.getTag(R.id.item_key_position);
        if (tag != null && tag instanceof Integer){
            int position = (int) tag;
            Object o = v.getTag(R.id.item_key_status);

            if (onRecyclerViewItemClickListener != null && o instanceof CategoryNames){
                onRecyclerViewItemClickListener.onItemClick(v,position,o);
            }
        }
    }


    static class ViewHolder extends RecyclerView.ViewHolder {



        ViewHolder(@NonNull View itemView) {
            super(itemView);


        }


        void setData(final Integer post) {

        }
    }
}
